package com.xxl.sso.core.api;

import com.alibaba.algo.cooperation.common.BaseResult;
import com.xxl.sso.core.entity.vo.req.SysCacheAddUpdateReqVO;
import com.xxl.sso.core.entity.vo.req.SysCacheKeyCacheValueReqVO;
import com.xxl.sso.core.entity.vo.req.SysCacheKeyReqVO;
import com.xxl.sso.core.entity.vo.res.SysCacheResVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @ClassName SysCacheFeignApi
 * @Description 缓存feign接口
 * @Author wangke
 * @Date 2021/9/26 16:23
 */

@FeignClient(url = "${feign.ssoServerUrl:}", value = "${feign.serverName}" ,path = "${feign.contextPath}")
@Component
public interface SysCacheFeignService {

    @RequestMapping(value = "/usercenter/sysCache/cacheValAqusitionByCacheKey", method = RequestMethod.POST)
    public BaseResult<SysCacheResVO> cacheValAqusitionByCacheKey(@RequestBody SysCacheKeyReqVO vo);

    @RequestMapping(value = "/usercenter/sysCache/cacheRefreshing", method = RequestMethod.POST)
    public BaseResult cacheRefreshing(@RequestBody SysCacheAddUpdateReqVO vo);

    @RequestMapping(value = "/usercenter/sysCache/cacheEvictionByCacheKey", method = RequestMethod.POST)
    public BaseResult cacheEvictionByCacheKey(@RequestBody SysCacheKeyReqVO vo);

    @RequestMapping(value = "/usercenter/sysCache/put", method = RequestMethod.POST)
    BaseResult put(@RequestBody SysCacheKeyCacheValueReqVO vo);

    @RequestMapping(value = "/usercenter/sysCache/get", method = RequestMethod.GET)
    BaseResult<String> get(@RequestParam("storeKey") String storeKey);

    @RequestMapping(value = "/usercenter/sysCache/removeByPrefix", method = RequestMethod.GET)
    BaseResult<Boolean> removeByPrefix(@RequestParam("prefix")String prefix);
}
